package com.sanqi.web.controller.work;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sanqi.common.annotation.Log;
import com.sanqi.common.core.controller.BaseController;
import com.sanqi.common.core.domain.AjaxResult;
import com.sanqi.common.enums.BusinessType;
import com.sanqi.work.domain.WorkScoringConf;
import com.sanqi.work.service.IWorkScoringConfService;
import com.sanqi.common.utils.poi.ExcelUtil;
import com.sanqi.common.core.page.TableDataInfo;

/**
 * 绩效考核配置Controller
 * 
 * @author duany
 * @date 2025-09-30
 */
@RestController
@RequestMapping("/work/scroconf")
@Api(tags="绩效考核配置")
public class WorkScoringConfController extends BaseController
{
    @Autowired
    private IWorkScoringConfService workScoringConfService;

    /**
     * 查询绩效考核配置列表
     */
    @PreAuthorize("@ss.hasPermi('work:scroconf:list')")
    @GetMapping("/list")
    @ApiOperation(value="绩效考核配置-查询绩效考核配置列表", notes="绩效考核配置-查询绩效考核配置列表")
    public TableDataInfo list(WorkScoringConf workScoringConf)
    {
        startPage();
        List<WorkScoringConf> list = workScoringConfService.selectWorkScoringConfList(workScoringConf);
        return getDataTable(list);
    }

    /**
     * 导出绩效考核配置列表
     */
    @PreAuthorize("@ss.hasPermi('work:scroconf:export')")
    @Log(title = "绩效考核配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value="绩效考核配置-导出绩效考核配置列表", notes="绩效考核配置-导出绩效考核配置列表")
    public void export(HttpServletResponse response, WorkScoringConf workScoringConf)
    {
        List<WorkScoringConf> list = workScoringConfService.selectWorkScoringConfList(workScoringConf);
        ExcelUtil<WorkScoringConf> util = new ExcelUtil<WorkScoringConf>(WorkScoringConf.class);
        util.exportExcel(response, list, "绩效考核配置数据");
    }

    /**
     * 获取绩效考核配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:scroconf:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value="绩效考核配置-获取绩效考核配置详细信息", notes="绩效考核配置-获取绩效考核配置详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(workScoringConfService.selectWorkScoringConfById(id));
    }

    /**
     * 新增绩效考核配置
     */
    @PreAuthorize("@ss.hasPermi('work:scroconf:add')")
    @Log(title = "绩效考核配置", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="绩效考核配置-新增绩效考核配置", notes="绩效考核配置-新增绩效考核配置")
    public AjaxResult add(@RequestBody WorkScoringConf workScoringConf)
    {
        return toAjax(workScoringConfService.insertWorkScoringConf(workScoringConf));
    }

    /**
     * 修改绩效考核配置
     */
    @PreAuthorize("@ss.hasPermi('work:scroconf:edit')")
    @Log(title = "绩效考核配置", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="绩效考核配置-修改绩效考核配置", notes="绩效考核配置-修改绩效考核配置")
    public AjaxResult edit(@RequestBody WorkScoringConf workScoringConf)
    {
        return toAjax(workScoringConfService.updateWorkScoringConf(workScoringConf));
    }

    /**
     * 删除绩效考核配置
     */
    @PreAuthorize("@ss.hasPermi('work:scroconf:remove')")
    @Log(title = "绩效考核配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	@ApiOperation(value="绩效考核配置-删除绩效考核配置", notes="绩效考核配置-删除绩效考核配置")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(workScoringConfService.deleteWorkScoringConfByIds(ids));
    }
}
